package com.sincon.system.controller;

import java.io.IOException;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sincon.common.annotation.Log;
import com.sincon.common.core.controller.BaseController;
import com.sincon.common.core.domain.AjaxResult;
import com.sincon.common.enums.BusinessType;
import com.sincon.system.domain.TbVideoInfo;
import com.sincon.system.service.ITbVideoInfoService;
import com.sincon.common.utils.poi.ExcelUtil;
import com.sincon.common.core.page.TableDataInfo;

/**
 * 视频任务三连配置Controller
 * 
 * @author LaoGao
 * @date 2024-12-23
 */
@RestController
@RequestMapping("/system/bilibiliTask")
public class TbVideoInfoController extends BaseController
{
    @Autowired
    private ITbVideoInfoService tbVideoInfoService;

    /**
     * 查询视频任务三连配置列表
     */
    @PreAuthorize("@ss.hasPermi('system:bilibiliTask:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbVideoInfo tbVideoInfo) throws IOException {
        startPage();
        List<TbVideoInfo> list = tbVideoInfoService.selectTbVideoInfoList(tbVideoInfo);
        return getDataTable(list);
    }

    /**
     * 导出视频任务三连配置列表
     */
    @PreAuthorize("@ss.hasPermi('system:bilibiliTask:export')")
    @Log(title = "视频任务三连配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbVideoInfo tbVideoInfo) throws IOException {
        List<TbVideoInfo> list = tbVideoInfoService.selectTbVideoInfoList(tbVideoInfo);
        ExcelUtil<TbVideoInfo> util = new ExcelUtil<TbVideoInfo>(TbVideoInfo.class);
        util.exportExcel(response, list, "视频任务三连配置数据");
    }

    /**
     * 获取视频任务三连配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:bilibiliTask:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tbVideoInfoService.selectTbVideoInfoById(id));
    }

    /**
     * 新增视频任务三连配置
     */
    @PreAuthorize("@ss.hasPermi('system:bilibiliTask:add')")
    @Log(title = "视频任务三连配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbVideoInfo tbVideoInfo)
    {
        return toAjax(tbVideoInfoService.insertTbVideoInfo(tbVideoInfo));
    }

    /**
     * 修改视频任务三连配置
     */
    @PreAuthorize("@ss.hasPermi('system:bilibiliTask:edit')")
    @Log(title = "视频任务三连配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbVideoInfo tbVideoInfo)
    {
        return toAjax(tbVideoInfoService.updateTbVideoInfo(tbVideoInfo));
    }

    /**
     * 删除视频任务三连配置
     */
    @PreAuthorize("@ss.hasPermi('system:bilibiliTask:remove')")
    @Log(title = "视频任务三连配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbVideoInfoService.deleteTbVideoInfoByIds(ids));
    }
}
